<extend name="template/base_index" />


<block name="area_header">
    <link rel="stylesheet" type="text/css" media="all" href="__CDN__/jquery-datetimepicker/jquery.datetimepicker.css">
    <!--<link type="text/css" rel="stylesheet" href="__CDN__/amazeui/2.3.0/css/amazeui.min.css" />-->
    <script type="text/javascript" src="__CDN__/jquery-datetimepicker/jquery.datetimepicker.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="__CSS__/zjqnew.css">
</block>

<block name="area_body">
    {:W('Menus/topbar')}
    <div class="admin-main container-fluid">
        {:W('Menus/left')}
        <div class="admin-main-content">
            {:W('Menus/breadcrumb')}
            <div class="filter-controls">
                <!-- 日期查询 -->
                <form action="{:U('WxWeb/product_manage')}" method="post" class="form-inline">
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">
                                商品类别
                            </div>
                            <select name="cate" class="form-control">
                                <option value="">=全部=</option>
                                <volist name="category_list" id="vo">
                                    <option <eq name="vo['id']" value="$cur_cate">selected</eq> value="{$vo.id}">{$vo.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <div class="input-group-addon">
                                商品名称
                                <i class="fa fa-calendar"></i>
                            </div>
                            <input type="text" name="name" id="enddatetime" class="form-control input-short" value="{$name}">
                        </div>
                    </div>
                    <button type="submit" class="btn btn-default btn-sm"><i class="fa fa-search"></i>查找</button>
                </form>
            </div>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th>ID</th><th>商品名称</th><th>创建时间</th><th>发布者微信号</th><th>商品状态</th><th>管理</th>
                </tr>
                </thead>
                <tbody>
                <empty name="list">
                    <tr>
                        <td colspan="6" class="text-center">{:L('NO_DATA')}</td>
                    </tr>
                    <else/>
                    <volist name="list" id="vo">
                        <tr>
                            <td>
                                {$vo.id}
                            </td>
                            <td>
                                {$vo.name}
                            </td>
                            <td>
                                {$vo.createtime|date='Y-m-d h:i:s',###}
                            </td>
                            <td>
                                {$vo.nickname}
                            </td>
                            <td>
                                <center>
                                    <eq name="vo['status']" value="0"><span class="p-work-off">商品已经售出</span></eq>
                                    <eq name="vo['status']" value="-2"><span class="p-undercarriage">等待审核上架</span></eq>
                                    <eq name="vo['status']" value="1"><span class="p-for-sale">商品在售</span></eq>
                                </center>
                            </td>
                            <td>
                                <a data-href="{:U('WxWeb/product_detail',array('id'=>$vo['id']))}" target="_blank" class="btn btn-sm btn-primary view-product" data-toggle="modal" data-target="#product_detail"><i class="fa fa-eye"></i>查看</a>
                                <eq name="vo['status']" value="1"><a data-href="{:U('WxWeb/ajax_undercarriage',array('id'=>$vo['id'],'hightlow'=>'low','openid' => $vo['openid']))}" class="btn btn-sm btn-danger undercarriage" data-toggle="modal" data-target=".bs-example-modal-lg"><i class="fa fa-trash"></i>审核不通过下架</a></eq>
                                <eq name="vo['status']" value="-2"><a data-href="{:U('WxWeb/ajax_undercarriage',array('id'=>$vo['id'],'hightlow'=>'hight','openid' => $vo['openid']))}" class="btn btn-sm btn-success upper-ajax" data-toggle="modal" data-target=".upper-modal"><i class="fa fa-trash"></i>审核通过上架</a></eq>
                            </td>
                        </tr>
                    </volist>
                </empty>
                </tbody>
            </table>
            <center><div>{$show}</div></center>
        </div>
        <!-- END admin-main-content -->
    </div>
    <!-- END admin-main-->
    <script>
        $(function(){
            $('.undercarriage').bind("click",function(){
                $('#ajax_url').val($(this).attr('data-href'));
            });
            /*绑定上架的地址信息*/
            $('.upper-ajax').bind("click",function(){
                $('#upperurl').val($(this).attr('data-href'));
            });
            /*c查看商品详情*/
            $('.view-product').bind("click",function(){
                var url = $(this).attr('data-href');
                $.get(url,function(data){
                    var data =  eval('('+data+')');
                    console.log(data);
                    $("#product_detail .user-img img").attr('src',data.avatar);
                    $("#product_detail .user-name").html("用户名称：" + data.nickname);
                    $("#product_detail .product-name").html("商品名称：" + data.name);
                    $("#product_detail .product-price").html("价格：" + data.price);
                    $(".product-brief p").text(data.synopsis);
                    $(".product_imglist ul").empty();
                    for (var i=0;i<data.imglist.length;i++)
                    {
                        $(".product_imglist ul").append('<li><img src='+data.imglist[i].imgurl+'></li>');
                    }
                })
            });
        });
        /*商品下架异步操作*/
        function ajax_undercarriage(){
            var url =  $('#ajax_url').val();
            var reason = $("[name='reason']").val();
            $.get(url,{reason:reason},function(msg){
                $('#ajax_url').val('');
                $('.bs-example-modal-lg').modal('hide');
                window.location.reload();
            });
        }
        /*商品上架异步操作*/
        function ajax_upper(){
            var url =  $('#upperurl').val();
            console.log(url);
            $.get(url,function(msg){
                $('#upperurl').val('');
                $('.upper-modal').modal('hide');
                window.location.reload();
            });
        }
    </script>
    <!--下架弹窗-->
    <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" style="display: none;">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title" id="myLargeModalLabel">下架原因</h4>
                </div>
                <div class="modal-body">
                    <textarea class="form-control" rows="3" name="reason"></textarea>
                    <input type="hidden" value=""  id="ajax_url">
                    <center><button class="btn btn-danger m-cancel" data-dismiss="modal">取消</button><button class="btn btn-warning m-ensure" onclick="ajax_undercarriage()">确定</button></center>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
    <!--商品上架弹窗-->
    <div class="modal fade upper-modal">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                    <h4 class="modal-title">商品上架提示</h4>
                </div>
                <div class="modal-body">
                    <p>您确定要将该商品上架？</p>
                    <input type="hidden" id="upperurl" >
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="button" class="btn btn-primary" onclick="ajax_upper()">确定</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div><!-- /.modal -->
    <!--商品详情弹窗-->
    <div class="modal fade " id="product_detail" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" style="display: none;">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                    <h4 class="modal-title" >商品详情</h4>
                </div>
                <div class="modal-body">
                    <div class="product-info clearfix"><div class="user-img"><img src="__IMG__/1.jpg"></div><div class="user-info"><span class="user-name"></span><br/><span class="product-name"></span><br/><span class="product-price"></span></div></div>
                    <div class="product-brief"><p>商品的详细情况</p></div>
                    <div class="product_imglist clearfix">
                        <ul>

                        </ul>
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
</block>

<block name="area_footer">

</block>